<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>cesium|可视域分析 | 一只咸鱼 | 努力学习最新姿势！！！</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="Cesium">
    <meta name="description" content="效果可视域在三维中是比较常用的分析功能，很多领域中都能应用到。   示例创建起终点，模拟相机的视锥绘制视锥体，创建点光源添加阴影效果。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707">
<meta property="og:type" content="article">
<meta property="og:title" content="cesium|可视域分析">
<meta property="og:url" content="http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/index.html">
<meta property="og:site_name" content="一只咸鱼">
<meta property="og:description" content="效果可视域在三维中是比较常用的分析功能，很多领域中都能应用到。   示例创建起终点，模拟相机的视锥绘制视锥体，创建点光源添加阴影效果。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20200412134023606.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20200412134206628.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70">
<meta property="article:published_time" content="2020-04-12T05:53:00.000Z">
<meta property="article:modified_time" content="2020-04-12T07:18:14.037Z">
<meta property="article:author" content="Mr.Zhang">
<meta property="article:tag" content="Cesium">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20200412134023606.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70">
    
        <link rel="alternate" type="application/atom+xml" title="一只咸鱼" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">Mr.Zhang</h5>
          <a href="mailto:zhangticcc@163.com" title="zhangticcc@163.com" class="mail">zhangticcc@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                首页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                时间轴
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://weibo.com/u/5392412243" target="_blank" >
                <i class="icon icon-lg icon-weibo"></i>
                微博
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/zhangti0708" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                开源地址
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://blog.csdn.net/weixin_40902527" target="_blank" >
                <i class="icon icon-lg icon-rss"></i>
                技术博客
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://zhangticcc.gitee.io/webgis/" target="_blank" >
                <i class="icon icon-lg icon-globe"></i>
                GIS案例
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://mp.weixin.qq.com/s/p4TOhKcr4RZkZWzuMYyBEQ" target="_blank" >
                <i class="icon icon-lg icon-weixin"></i>
                微信订阅号
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">cesium|可视域分析</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">cesium|可视域分析</h1>
        <h5 class="subtitle">
            
                <time datetime="2020-04-12T05:53:00.000Z" itemprop="datePublished" class="page-time">
  2020-04-12
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/GIS/">GIS</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#效果"><span class="post-toc-number">1.</span> <span class="post-toc-text">效果</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#示例"><span class="post-toc-number">2.</span> <span class="post-toc-text">示例</span></a></li></ol>
        </nav>
    </aside>


<article id="post-cesium-可视域分析实现"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">cesium|可视域分析</h1>
        <div class="post-meta">
            <time class="post-time" title="2020-04-12 13:53:00" datetime="2020-04-12T05:53:00.000Z"  itemprop="datePublished">2020-04-12</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/GIS/">GIS</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h3 id="效果"><a href="#效果" class="headerlink" title="效果"></a>效果</h3><p><code>可视域在三维中是比较常用的分析功能，很多领域中都能应用到。</code><br><img alt="" height="430" src="https://img-blog.csdnimg.cn/20200412134023606.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70" width="700"></p>
<img alt="" height="430" src="https://img-blog.csdnimg.cn/20200412134206628.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70" width="700">

<h3 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h3><p>创建起终点，模拟相机的视锥绘制视锥体，创建点光源添加阴影效果。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br></pre></td><td class="code"><pre><span class="line">import Coordinate from &#39;..&#x2F;..&#x2F;BaseTool&#x2F;Coordinate&#39;;</span><br><span class="line">import Cesium from &#39;Cesium&#39;</span><br><span class="line">import PointDrawer from &#39;..&#x2F;..&#x2F;BaseTool&#x2F;Draw&#x2F;DrawPoint&#39;;</span><br><span class="line">export default class Viewshed &#123;</span><br><span class="line">    &#x2F;&#x2F; viewer: any;</span><br><span class="line">    &#x2F;&#x2F; vishedfrustum: any &#x3D; null;</span><br><span class="line">    &#x2F;&#x2F; pointEntities: any[] &#x3D; [];</span><br><span class="line"></span><br><span class="line">    constructor(viewer) &#123;</span><br><span class="line">        this.viewer &#x3D; viewer;</span><br><span class="line">        this.pointEntities &#x3D; [];</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    init(pointArr) &#123;</span><br><span class="line">        if(pointArr.length &#x3D;&#x3D;&#x3D; 1)&#123;</span><br><span class="line">            this.pointEntities.push(PointDrawer.draw(this.viewer, pointArr[0], 10, Cesium.Color.AQUAMARINE))</span><br><span class="line">        &#125;</span><br><span class="line">        else if(pointArr.length &#x3D;&#x3D;&#x3D; 2)&#123;</span><br><span class="line">            this.pointEntities.push(PointDrawer.draw(this.viewer, pointArr[0], 10, Cesium.Color.AQUAMARINE));</span><br><span class="line">            this.pointEntities.push(PointDrawer.draw(this.viewer, pointArr[1], 10, Cesium.Color.AQUAMARINE));</span><br><span class="line">            this.createViewshedMap(pointArr[0], pointArr[1]);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    exit() &#123;</span><br><span class="line">        &#x2F;&#x2F;clear point arr</span><br><span class="line">        this.pointEntities.forEach(item &#x3D;&gt; &#123;</span><br><span class="line">            this.viewer.entities.remove(item);</span><br><span class="line">        &#125;);</span><br><span class="line">        this.pointEntities &#x3D; [];</span><br><span class="line">        &#x2F;&#x2F;stop shadowMap</span><br><span class="line">        &#x2F;&#x2F; PopCity.viewer.scene.shadowMap.enabled &#x3D; false;</span><br><span class="line">        &#x2F;&#x2F;clear primitive</span><br><span class="line">        if (this.vishedfrustum) &#123;</span><br><span class="line">            this.viewer.scene.primitives.remove(this.vishedfrustum);</span><br><span class="line">            this.vishedfrustum &#x3D; false;</span><br><span class="line">        &#125;</span><br><span class="line">        this.viewer.scene.primitives._primitives.forEach((item, index) &#x3D;&gt; &#123;</span><br><span class="line">            if (item.name &#x3D;&#x3D;&#x3D; &#39;VIEWSHEDPRIMITIVE&#39;) &#123;</span><br><span class="line">                this.viewer.scene.primitives._primitives.splice(index, 1);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">		&#x2F;&#x2F;核心代码</span><br><span class="line">    createViewshedMap(start, end) &#123;</span><br><span class="line">        var scene &#x3D; this.viewer.scene;</span><br><span class="line">        var spotLightCamera &#x3D; new Cesium.Camera(scene);</span><br><span class="line">        spotLightCamera.position &#x3D; start;</span><br><span class="line">        spotLightCamera.direction &#x3D; this.calculateDirection(start, end);</span><br><span class="line">        spotLightCamera.up &#x3D; Cesium.Cartesian3.clone(this.viewer.camera.up);</span><br><span class="line">        spotLightCamera.frustum.fov &#x3D; Cesium.Math.PI_OVER_THREE;</span><br><span class="line">        spotLightCamera.frustum.near &#x3D; 0.1;</span><br><span class="line">        spotLightCamera.frustum.far &#x3D; Cesium.Cartesian3.distance(start, end);</span><br><span class="line"></span><br><span class="line">        &#x2F;&#x2F;绘制视锥体</span><br><span class="line">        this.drawFrustum(start, end, spotLightCamera.frustum);</span><br><span class="line"></span><br><span class="line">        var viewshedOptions &#x3D; &#123;</span><br><span class="line">            context: scene.context,</span><br><span class="line">            lightCamera: spotLightCamera,</span><br><span class="line">            cascadesEnabled: false,</span><br><span class="line">            softShadows: true,</span><br><span class="line">            viewshed: true</span><br><span class="line">        &#125;;</span><br><span class="line"></span><br><span class="line">        var viewshed &#x3D; new Cesium.ShadowMap(viewshedOptions);</span><br><span class="line">        viewshed.enabled &#x3D; true;</span><br><span class="line">        viewshed.size &#x3D; 1024;</span><br><span class="line"></span><br><span class="line">        &#x2F;&#x2F; const ViewshedPrimitive &#x3D; function(this, shadowMap) &#123;</span><br><span class="line">        &#x2F;&#x2F;     this.shadowMap &#x3D; shadowMap;</span><br><span class="line">        &#x2F;&#x2F;     this.name &#x3D; &#39;VIEWSHEDPRIMITIVE&#39;;</span><br><span class="line">        &#x2F;&#x2F; &#125;</span><br><span class="line">        &#x2F;&#x2F; var that &#x3D; this;</span><br><span class="line">        const ViewshedPrimitive &#x3D; function(shadowMap) &#123;</span><br><span class="line">            this.shadowMap &#x3D; shadowMap;</span><br><span class="line">            this.name &#x3D; &#39;VIEWSHEDPRIMITIVE&#39;;</span><br><span class="line">        &#125;;</span><br><span class="line"></span><br><span class="line">        ViewshedPrimitive.prototype.update &#x3D; function(frameState) &#123;</span><br><span class="line">            frameState.shadowMaps.push(this.shadowMap);</span><br><span class="line">        &#125;;</span><br><span class="line"></span><br><span class="line">        scene.primitives.add(new ViewshedPrimitive(viewshed));</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    &#x2F;&#x2F;计算方向</span><br><span class="line">    calculateDirection(p1, p2) &#123;</span><br><span class="line">        return Cesium.Cartesian3.normalize(</span><br><span class="line">            Cesium.Cartesian3.subtract(p2, p1, new Cesium.Cartesian3()),</span><br><span class="line">            new Cesium.Cartesian3()</span><br><span class="line">        );</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    drawFrustum(position1, position2, frustum) &#123;</span><br><span class="line">        var orientation &#x3D; this.calculateorigntation(position1, position2);</span><br><span class="line"></span><br><span class="line">        var primitive &#x3D; new Cesium.Primitive(&#123;</span><br><span class="line">            geometryInstances: new Cesium.GeometryInstance(&#123;</span><br><span class="line">                geometry: new Cesium.FrustumOutlineGeometry(&#123;</span><br><span class="line">                    frustum: frustum,</span><br><span class="line">                    origin: position1,</span><br><span class="line">                    orientation: orientation</span><br><span class="line">                &#125;),</span><br><span class="line">                attributes: &#123;</span><br><span class="line">                    color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 1.0, 0.0, 1.0))</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;),</span><br><span class="line">            appearance: new Cesium.PerInstanceColorAppearance(&#123;</span><br><span class="line">                flat: true</span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;);</span><br><span class="line"></span><br><span class="line">        this.viewer.scene.primitives.add(primitive);</span><br><span class="line"></span><br><span class="line">        this.vishedfrustum &#x3D; primitive;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    calculateorigntation(p1, p2) &#123;</span><br><span class="line">        var co1 &#x3D; Coordinate.cartesian2lonlat(p1);</span><br><span class="line">        var co2 &#x3D; Coordinate.cartesian2lonlat(p2);</span><br><span class="line"></span><br><span class="line">        var width &#x3D; Coordinate.catchDistancefromCartographic2D(</span><br><span class="line">            co1.longitude,</span><br><span class="line">            co1.latitude,</span><br><span class="line">            co2.longitude,</span><br><span class="line">            co1.latitude</span><br><span class="line">        );</span><br><span class="line">        var length &#x3D; Coordinate.catchDistancefromCartographic2D(</span><br><span class="line">            co1.longitude,</span><br><span class="line">            co1.latitude,</span><br><span class="line">            co1.longitude,</span><br><span class="line">            co2.latitude</span><br><span class="line">        );</span><br><span class="line">        var height &#x3D; co1.height - co2.height;</span><br><span class="line">        var distance &#x3D; Coordinate.catchDistancefromCartographic2D(</span><br><span class="line">            co1.longitude,</span><br><span class="line">            co1.latitude,</span><br><span class="line">            co2.longitude,</span><br><span class="line">            co2.latitude</span><br><span class="line">        );</span><br><span class="line"></span><br><span class="line">        var angle &#x3D; Math.atan(width &#x2F; length);</span><br><span class="line">        var tilt &#x3D; Math.atan(height &#x2F; distance);</span><br><span class="line"></span><br><span class="line">        if (co1.latitude &gt; co2.latitude) &#123;</span><br><span class="line">            angle &#x3D; Math.PI - angle;</span><br><span class="line">        &#125;</span><br><span class="line">        if (co1.longitude &gt; co2.longitude) &#123;</span><br><span class="line">            angle &#x3D; -angle;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        var heading &#x3D; angle;</span><br><span class="line">        var pitch &#x3D; 0;</span><br><span class="line">        var roll &#x3D; -Math.PI &#x2F; 2 - tilt;</span><br><span class="line">        var hpr &#x3D; new Cesium.HeadingPitchRoll(heading, pitch, roll);</span><br><span class="line">        var orientation &#x3D; Cesium.Transforms.headingPitchRollQuaternion(p1, hpr);</span><br><span class="line"></span><br><span class="line">        return orientation;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    clearDraw() &#123;</span><br><span class="line">        &#x2F;&#x2F;清除点</span><br><span class="line">        if (this.pointEntities &amp;&amp; this.pointEntities.length &gt; 0) &#123;</span><br><span class="line">            for (var i &#x3D; 0; i &lt; this.pointEntities.length ; i++) &#123;</span><br><span class="line">                this.viewer.entities.remove(this.pointEntities[i]);</span><br><span class="line">                &#x2F;&#x2F; pointArr.splice(i,1);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        &#x2F;&#x2F;清除视锥</span><br><span class="line">        if (this.vishedfrustum) &#123;</span><br><span class="line">            this.viewer.scene.primitives.remove(this.vishedfrustum);</span><br><span class="line">        &#125;</span><br><span class="line">        &#x2F;&#x2F;清除阴影</span><br><span class="line">        this.viewer.scene.primitives._primitives.forEach((item, index) &#x3D;&gt; &#123;</span><br><span class="line">            if (item.name &#x3D;&#x3D;&#x3D; &#39;VIEWSHEDPRIMITIVE&#39;) &#123;</span><br><span class="line">                this.viewer.scene.primitives._primitives.splice(index, 1);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>实现效果比较粗糙</p>
<p>开源地址:<a href="https://github.com/diken666/simpleC" target="_blank" rel="noopener">github地址</a></p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2020-04-12T07:18:14.037Z" itemprop="dateUpdated">2020-04-12 15:18:14</time>
</span><br>


        
        这里可以写作者留言，标签和 hexo 中所有变量及辅助函数等均可调用，示例：<a href="/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/" target="_blank" rel="external">http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/</a>
        
    </div>
    
    <footer>
        <a href="http://yoursite.com">
            <img src="/img/avatar.jpg" alt="Mr.Zhang">
            Mr.Zhang
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Cesium/" rel="tag">Cesium</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/&title=《cesium|可视域分析》 — 一只咸鱼&pic=http://yoursite.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/&title=《cesium|可视域分析》 — 一只咸鱼&source=分享各种福利和姿势..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《cesium|可视域分析》 — 一只咸鱼&url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2020/04/12/cesium-%E9%80%9A%E8%A7%86%E5%88%86%E6%9E%90/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">cesium|通视分析</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2020/04/11/Vue/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">Vue|父子组件的通信</h4>
      </a>
    </div>
  
</nav>



    




















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢大爷~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/wechat.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="/img/wechat.jpg" data-alipay="/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>Mr.Zhang &copy; 2015 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/&title=《cesium|可视域分析》 — 一只咸鱼&pic=http://yoursite.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/&title=《cesium|可视域分析》 — 一只咸鱼&source=分享各种福利和姿势..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《cesium|可视域分析》 — 一只咸鱼&url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://yoursite.com/2020/04/12/cesium-%E5%8F%AF%E8%A7%86%E5%9F%9F%E5%88%86%E6%9E%90%E5%AE%9E%E7%8E%B0/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
